<template>
<div>
	<div class="mui-content">          
			<form class="mui-input-group">
                <div class="mui-input-row"> 
                    <router-link to="/user/head" v-model="u_icon" id="u_icon">
                    <label>头像</label>
                      <img :src="imgurl+img" >
                    </router-link>
				</div>
				<div class="mui-input-row">
					<label>账号<span class="fk">*</span></label>
					<input id='u_account' type="text" class="mui-input-clear mui-input" v-model="u_account"  placeholder="请输入账号">
				</div>
                <div class="mui-input-row">
					<label>昵称<span class="fk">*</span></label>
					<input id='u_nickname' type="text" class="mui-input-clear mui-input" v-model="u_nickname" placeholder="请输入账号">
				</div>
				<div class="mui-input-row">
					<label>密码<span class="fk">*</span></label>
					<input id='u_password' type="password" class="mui-input-clear mui-input" v-model="u_password" placeholder="请输入密码">
				</div>
                <div class="mui-input-row">
					<label>性别<span class="fk">*</span></label>
                    <select id="u_gender" v-model="u_gender">
                        <option value="男" >男</option>
                        <option value="女">女</option>
                    </select>
				</div>
				<div class="mui-input-row">
					<label>手机号<span class="fk">*</span></label>
					<input id='u_phone' type="text" class="mui-input-clear mui-input" v-model="u_phone" placeholder="请输入手机号">
				</div>
				<div class="mui-input-row">
					<label>邮箱<span class="fk">*</span></label>
					<input id='u_email' type="email" class="mui-input-clear mui-input" v-model="u_email" placeholder="请输入邮箱">
				</div>
                <div class="mui-input-row">
					<label>身份证号</label>
					<input id='u_idCard' type="text" class="mui-input-clear mui-input" v-model="u_idCard" placeholder="请输入身份证号">
				</div>
                <div class="read">
					<label>带 <span class="fk">*</span> 都为必填项</label>
				</div>
			</form>
			<div class="mui-content-padded">

				<button type="button" class="mui-btn mui-btn-block mui-btn-primary" @click="addusers">注册</button>
			</div>
           
		</div>
</div>
</template>

<script>
import {Toast} from 'mint-ui'
export default {
   data(){
       return{    
          img:this.$route.params.img,
          u_icon:'',
          u_account:'',
          u_nickname:'',
          u_password:'',
          u_gender:'男',
          u_phone:'',
          u_email:'',
          u_idCard:'',
          imgurl:'http://localhost:3000/images/Head/'
       }
   },
   methods:{
         addusers(){
            if(this.u_account.trim()==""){
                 Toast("账号不能为空");
                    return;
            }
            if(this.u_nickname.trim()==""){
                 Toast("昵称不能为空");
                    return;
            }
            if(this.u_password.trim()==""){
                 Toast("密码不能为空");
                    return;
            }    
            if(this.u_phone.trim()==""){
                Toast("手机号不为空");    
                    return
            }
            if(this.u_email.trim()==""){
                Toast("邮箱不能为空"); 
                    return                   
            }
            if(this.u_idCard.trim()==""){
                this.u_idCard = " ";
            }
            let person = {      
                "u_icon":this.img,
                "u_account":this.u_account,
                "u_nickname":this.u_nickname,
                "u_password":this.u_password,
                "u_gender":this.u_gender,
                "u_phone":this.u_phone,
                "u_email":this.u_email,
                "u_idCard":this.u_idCard
            }
           
            this.$ajax({
                url:"before/adduser",
                method:"post",
                data:person
            }).then(resp=>{
                if(resp.data.status==1){
                    Toast('注册成功')              
                    this.$router.push("/user/login")
                }else{
                    Toast(resp.data.message)
                }
               
            });
            
        },
        
   },
   created(){
     
   }
}
</script>

<style  scoped>
.mui-content{
    top: 40px;
}
img{
    width:40px ;
    height: 40px;
}
.fk{
    color: red;
}
.read{
    width: 100%;
    height: 40px;
    line-height: 40px;
    margin-left: 15px;
}
</style>

